<template>
  <div>
    <h2>用户登录</h2>
    <el-input v-model="user.username"></el-input>
    <el-input type="password" v-model="user.password"></el-input>
    <el-button @click="onLogin">登录</el-button>

    <el-button @click="testInject">testInject</el-button>
  </div>
</template>

<script>
import { setToken,removeToken } from '@/utils/auth'
export default {
  layout: "blank",
  data() {
    return {
      user: {
        username: "",
        password: ""
      }
    };
  },
  methods: {
    testInject(){
      this.$testInject();
      console.log(process.env);
    },
    loginOut(){
      removeToken();
    },
    onLogin() {
      setToken("222")
      const redirect = this.$route.query.redirect || "/";
      this.$router.push(redirect);
      // this.$store.dispatch("user/login", this.user).then(ok => {
      //   // 登录成功重定向
      //   if (ok) {
      //     const redirect = this.$route.query.redirect || "/";
      //     this.$router.push(redirect);
      //   }
      // });
    }
  }
};
</script>
